import { request } from "@/utils/service"
import {
  AdvertisingDataItem,
  AppendUserInfo,
  EditUserInfo,
  QueryUserInfoTableParams,
  QueryUserInfoTableResponse
} from "./types/info"

// 新增用户
export function appendUserInfo(data: AppendUserInfo) {
  return request({
    url: "user/add",
    method: "post",
    data
  })
}

// 删除用户
export function deleteUserInfo(id: number) {
  return request({
    url: "user/delete",
    method: "post",
    data: {
      id
    }
  })
}

// 修改用户数据
export function updateUserInfo(data: EditUserInfo) {
  return request({
    url: "user/update",
    method: "post",
    data
  })
}

// 查看用户数据
export function getUserInfoTableData(data: QueryUserInfoTableParams) {
  return request<QueryUserInfoTableResponse>({
    url: "user/list/page",
    method: "post",
    data
  })
}

// 获取广告列表
export function getAdvertisingData() {
  return request<ApiResponseData<AdvertisingDataItem[]>>({
    url: "advertising/list",
    method: "get"
  })
}
